#!/bin/bash

lc=$1
rhost=$2
rlogin=$3
rpasswd=$4
dbnmame=$5
dblogin=$6
dbpassword=$7
archivepassword=$8
productionday=$9

print_usage()
{
    echo "Usage: $0 <logistic center> <rhost> <rlogin> <rpasswd> <dbname> <dblogin> <dbpassword> <archivepassword> <productionday>"
    echo "Download the production data of the given day."
}

if [ "x$productionday" == "x" ]; then
   echo "[ERROR] All arguments not available."
   print_usage
   exit 1
fi

/data/scripts/retrieve_data_lc.pl $lc $rhost $rlogin $rpasswd $dbnmame $dblogin $dbpassword $archivepassword $productionday
error=`grep "\[ERROR\]" /tmp/retrieve_data_$lc.log`
res=$?
if [ $res -eq 0 ]; then
    /data/scripts/sendmail.pl -f multisimgen.support@tcl.com -t raffi.semerciyan@jrdcom.com -s "Multisimgen >retrieve_data_lc.sh-$lc< notification" /tmp/retrieve_data_$lc.log
fi
